<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Combo
 *
 * @author luiscarlosch@gmail.com
 */
class ComboBox {
    private $elements;
    private $defaultIndex;
    public function ComboBox(){

    }

    public function setElements($elements,$defaultIndex){
        $this->elements=$elements;
        $this->defaultIndex=$defaultIndex;
    }

    public function toString(){
        $content= '<select>';
        

            for($i=0; $i<count($this->elements); $i++){
                if($this->defaultIndex==$i){//Set the default item displayed
                    $content.=  '<option selected>'.$this->elements[$i].'  </option>';
                }
                else{
                    $content.=  '<option>'.$this->elements[$i].' </option>';
                }
            }
  
        $content.=  '</select>';
        return $content;
    }
}
?>
